﻿@model PhoneBilling.Models.GradeDetailMgtModel
@{
    ViewBag.Title = "收费等级管理";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<div class="grade_detail_mgt">
<script type="text/javascript">
    function changeGrade() {
        window.location.href = "/Manage/GradeDetailMgt/" + $("#gradeList").val();
    }
    function del(id, name,grade) {
        var r = confirm("确认删除话类：" + name + "吗？");
        if (r == true) {
            window.location.href = "/Manage/GradeDetailDelete?areaType=" + id + "&gradeID=" + grade;
        }
        return false;
    }
</script>
<script type="text/javascript">
    $(document).ready(function () {
        $("#btnNewGradeDetailEdit").ligerButton(
        {
            width: 150,
            click: function () {
                window.location.href = "/Manage/GradeDetailEdit?gradeID=@Model.CurrentGrade";
            }
        });
        $("#btnGradeDetailMonthEdit").ligerButton(
        {
            click: function () {
                window.location.href = "/Manage/GradeDetailMonthEdit?gradeID=@Model.CurrentGrade";
            }
        });
    });
</script>
@if (Model.Message != null){<h2>@Model.Message</h2>}
<div class="system_input_contain">
    当前收费等级表: @Html.DropDownListFor(m => m.CurrentGrade, new SelectList(Model.GradeList, "ID", "Name"), new { id = "gradeList", style = "input-text", onchange = "changeGrade()" }) 
    <input type="button" id="btnNewGradeDetailEdit" value="新增收费等级表明细" />
    <input type="button" id="btnGradeDetailMonthEdit" value="月租设定" />
</div>                                                   
@{
    System.Text.StringBuilder sb = new System.Text.StringBuilder();
    sb.AppendLine(string.Format("var data={{Total:{0},", Model.GradeDetailList.Count));
    sb.AppendLine("Rows:[");
    for (int i = 0; i < Model.GradeDetailList.Count; i++)
    {
        var item = Model.GradeDetailList[i];
        if(i == 0)
        {
            sb.Append("{");
        }
        else
        {
            sb.Append(",{");
        }
        sb.Append(string.Format("话类:'{0}',", item.话类));
        sb.Append(string.Format("最小计费延时:'{0}',", item.最小计费延时));
        sb.Append(string.Format("时长误差:'{0}',", item.时长误差));
        sb.Append(string.Format("最小计次次数:'{0}',", item.最小计次次数));
        sb.Append(string.Format("服务费缩放系数:'{0}',", item.服务费缩放系数));
        sb.Append(string.Format("附加费按基本费的比例收取时的系数:'{0}',", item.附加费按基本费的比例收取时的系数));
        sb.Append(string.Format("服务费按基本费的比例收取时的系数:'{0}',", item.服务费按基本费的比例收取时的系数));
        sb.Append(string.Format("附加费按服务器的比例收取时的系数:'{0}',", item.附加费按服务器的比例收取时的系数));
        sb.Append(string.Format("单笔花费最小金额:'{0}',", item.单笔花费最小金额));
        sb.Append(string.Format("单笔花费最大金额:'{0}',", item.单笔花费最大金额));
        sb.Append(string.Format("包月话类收费起点:'{0}',", item.包月话类收费起点));
        sb.Append(string.Format("包月话类封顶限额:'{0}',", item.包月话类封顶限额));
        sb.Append(string.Format("取整方法:'{0}'", item.取整方法));
        sb.Append("}");
    }
    sb.AppendLine("]};");
    string data = sb.ToString();
}
<script type="text/javascript">
    @Html.Raw(data)
    
    var menu = $.ligerMenu({ top: 100, left: 100, width: 120, items:
            [
            { text: '新增', click: newclick },
            { line: true },
            { text: '修改', click: modifyclick },
            { line: true },
            { text: '删除', click: deleteclick }
            ]
        });
    var grid;
    $(function () {

        grid = $("#maingrid").ligerGrid({
            columns: [
                { display: '话类', name: '话类',width:80},
                { display: '最小计费延时', name: '最小计费延时',width:80},
                { display: '时长误差', name: '时长误差',width:80},
                { display: '最小计次次数', name: '最小计次次数',width:80},
                { display: '服务费缩放系数', name: '服务费缩放系数',width:100},
                { display: '附加费/基本费', name: '附加费按基本费的比例收取时的系数',width:100},
                { display: '服务费/基本费', name: '服务费按基本费的比例收取时的系数',width:100},
                { display: '附加费/服务费', name: '附加费按服务器的比例收取时的系数',width:100},
                { display: '单笔最小金额', name: '单笔花费最小金额',width:100},
                { display: '单笔最大金额', name: '单笔花费最大金额',width:100},
                { display: '包月收费起点', name: '包月话类收费起点',width:100},
                { display: '包月封顶限额', name: '包月话类封顶限额',width:100},
                { display: '服务费缩放系数', name: '服务费缩放系数',width:100},
                { display: '取整方法', name: '取整方法',width:80}
                ],
                isScroll: false, data: data,pageSize:30,alternatingRow:true,  
                onContextmenu: function (node, e) {
            actionNodeID = node;
            menu.show({ top: e.pageY, left: e.pageX });
            return false;
        }
        }
        );resetGridHeight(grid);
        $(window).resize(function () {
                resetGridHeight(grid);
            });
    });    function newclick(item, i) {
        var path = "/Manage/GradeDetailEdit?gradeID=@Model.CurrentGrade";
        window.location.href=path;
    }
    function modifyclick(item, i) {
        var path = "/Manage/GradeDetailEdit?gradeID=@Model.CurrentGrade&areaType="+actionNodeID.data.话类;
        window.location.href=path;
    }    function deleteclick(item, i) {
        del(actionNodeID.data.话类,actionNodeID.data.话类,'@Model.CurrentGrade');
    }
    $(document).ready(function () {
        $("#btnNew").ligerButton(
        {
            click: function () {
                window.location.href = "/Manage/GradeDetailEdit?gradeID=@Model.CurrentGrade";
            }
        });
        $("#btnModify").ligerButton(
        {
            click: function () {
                var row = grid.getSelectedRow();
                if(row != null)
                {
                    var path = "/Manage/GradeDetailEdit?gradeID=@Model.CurrentGrade&areaType="+row.话类;
                    window.location.href=path;
                }
            }
        });

        $("#btnDelete").ligerButton(
        {
            click: function () {
                var row = grid.getSelectedRow();
                if(row != null)
                {
                    del(row.话类,row.话类,'@Model.CurrentGrade');
                }
            }
        });
    });
</script>
<div class="system_input_contain">
    @Html.LabelFor(m => m.月租费)
    @Html.DisplayFor(m => m.月租费)
    @Html.LabelFor(m => m.功能费)
    @Html.DisplayFor(m => m.功能费)
    @Html.LabelFor(m => m.代维费)
    @Html.DisplayFor(m => m.代维费)
    @Html.LabelFor(m => m.免费额)
    @Html.DisplayFor(m => m.免费额)
    @Html.LabelFor(m => m.其他费)
    @Html.DisplayFor(m => m.其他费)
</div>
<div class="system_toolbar">
    <input type="button" id="btnNew" value="新增" />
    <input type="button" id="btnModify" value="修改" />
    <input type="button" id="btnDelete" value="删除" />
</div>
<div id="maingrid"></div>
</div>